Skip to content

Refactor/core cleanup#11

Merged
ericc-ch merged 30 commits intomasterfrom
refactor/core-cleanup
Mar 11, 2025
Merged

Refactor/core cleanup#11
ericc-ch merged 30 commits intomasterfrom
refactor/core-cleanup

Conversation

@ericc-ch
Copy link
Copy Markdown
Owner

No description provided.

@ericc-ch ericc-ch self-assigned this Mar 11, 2025
@ericc-ch ericc-ch mentioned this pull request Mar 11, 2025
@ericc-ch ericc-ch merged commit bb3462b into master Mar 11, 2025
@ericc-ch ericc-ch deleted the refactor/core-cleanup branch March 13, 2025 01:00
hao1939 pushed a commit to hao1939/copilot-api that referenced this pull request Nov 22, 2025
basiltt added a commit to basiltt/copilot-api that referenced this pull request Mar 16, 2026
…t fixes

Critical fixes:
- ericc-ch#4 Use WEB_SEARCH_FUNCTION_TOOL.function.name constant instead of hardcoded
  "web_search" string in interceptor — eliminates silent maintenance trap
- ericc-ch#9 Set tool_choice:"none" in second pass to prevent model from re-invoking
  web search, which would produce unresolvable finish_reason:"tool_calls" for
  the Anthropic client
- ericc-ch#10 Scope Path 2 preflight to only fire when the payload contains a custom
  tool whose name is in WEB_SEARCH_TOOL_NAMES — prevents firing on every
  Claude Code request (which always includes Bash/editor tools but never
  explicitly declares a web search tool)
- ericc-ch#18 Move WEB_SEARCH_FUNCTION_TOOL injection into interceptor via new
  prepareWebSearchPayload() — keeps tool injection co-located with the code
  that depends on it; handler no longer reaches into service internals

Important fixes:
- ericc-ch#1 Document rate-limit bypass in interceptor JSDoc and update startup log
  message to clarify internal calls are not counted against the rate limit
- ericc-ch#3 Simplify toolResultContent control flow — results and errors are assigned
  on every branch before buildSecondPass is called (no more nested try/catch)
- ericc-ch#6 getPreflightModel prefers cheap models (mini/flash/haiku/small heuristic)
  instead of "any model that isn't the request model"
- ericc-ch#11 Replace array index cast with Array.at() for natural undefined safety
- ericc-ch#13 Use XML delimiters in preflight prompt to prevent quote characters in
  user messages from breaking the classifier prompt (prompt injection fix)
- ericc-ch#14 Add consola.debug calls in interceptor for first/second pass payloads
  and responses so --verbose is useful for debugging web search issues
- ericc-ch#8 Add "// Web search configuration" section comment in State interface

Tests updated:
- Fix tool_choice test: second pass must use "none", not pass original value
- Add prepareWebSearchPayload tests (3 tests)
- Add Path 2 scoping tests: bash-only tools skip preflight; web_search custom
  tool fires preflight (2 tests)
- Add empty tools array test for Path 2 skip

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant